package moc.egg;
import moc.compiler.*;
import moc.tds.*;
import moc.type.*;
import moc.gc.*;
import java.util.*;
import moc.type.object.*;
import mg.egg.eggc.runtime.libjava.lex.*;
import mg.egg.eggc.runtime.libjava.*;
import mg.egg.eggc.runtime.libjava.messages.*;
import mg.egg.eggc.runtime.libjava.problem.IProblem;
import java.util.Vector;
public class S_METHODE_MOC {
LEX_MOC scanner;
  S_METHODE_MOC() {
    }
  S_METHODE_MOC(LEX_MOC scanner, boolean eval) {
    this.scanner = scanner;
    this.att_eval = eval;
    this.att_scanner = scanner;
    }
int [] sync= new int[0];
  int att_cpt_meth;
  String att_myclass;
  boolean att_eval;
  int att_incr;
  String att_code;
  IMachine att_machine;
  TDS att_tds;
  LEX_MOC att_scanner;
  CLASSE glob_83_c;
  boolean glob_83_const;
  private void regle83() throws Exception {

    //declaration
    S_QUAL_MOC x_2 = new S_QUAL_MOC(scanner,att_eval) ;
    S_PTYPE_MOC x_3 = new S_PTYPE_MOC(scanner,att_eval) ;
    S_MPARFS_MOC x_5 = new S_MPARFS_MOC(scanner,att_eval) ;
    S_BLOC_MOC x_7 = new S_BLOC_MOC(scanner,att_eval) ;
    //appel
if  (att_eval)      action_auto_inh_83(x_2, x_3, x_5, x_7);
    x_2.analyser() ;
    x_3.analyser() ;
if  (att_eval)      action_init_83(x_2, x_3, x_5, x_7);
    x_5.analyser() ;
if  (att_eval)      action_initBLOC_83(x_2, x_3, x_5, x_7);
    x_7.analyser() ;
if  (att_eval)      action_code_83(x_2, x_3, x_5, x_7);
  }
private void action_init_83(S_QUAL_MOC x_2, S_PTYPE_MOC x_3, S_MPARFS_MOC x_5, S_BLOC_MOC x_7) throws Exception {
try {
// instructions
x_5.att_hsignature= new SIGNATURE();
if (x_2.att_isStatic){
x_5.att_hdepLB=0;
}
else {
x_5.att_hdepLB=-(1);
}
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#init","METHODE -> QUAL PTYPE #init MPARFS #initBLOC BLOC #code ;"});
}
  }
private void action_initBLOC_83(S_QUAL_MOC x_2, S_PTYPE_MOC x_3, S_MPARFS_MOC x_5, S_BLOC_MOC x_7) throws Exception {
try {
// locales
TDS loc_tds;
INFOCLASS loc_infoc;
INFOMETHODE loc_infom;
// instructions
glob_83_const=x_2.att_isStatic&&x_5.att_metid.equals("init");
x_7.att_inconstructor=glob_83_const;
x_7.att_rtype=x_3.att_type;
x_7.att_hdep=3;
loc_tds= new TDS(this.att_tds);
loc_tds.inserer(x_5.att_signature);
loc_infoc=this.att_tds.chercherGlobalementClasse(this.att_myclass);
glob_83_c=loc_infoc.getClasse();
if (glob_83_const||x_2.att_isStatic==false){
loc_tds.inserer(glob_83_c.getAttributes());
}

x_7.att_tds=loc_tds;
if (glob_83_c.chercherMethodeLocale(x_5.att_metid)!=null){
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMOCMessages.id_Methode_definie, MOCMessages.Methode_definie,new Object[]{""+x_5.att_metid});

}
else {
loc_infom=glob_83_c.chercherMethode(x_5.att_metid);
if ((loc_infom!=null)){
glob_83_c.setDesc(glob_83_c.redefineMeth(x_5.att_metid));
this.att_incr=0;
}
else {
this.att_incr=1;
glob_83_c.addMeth(x_5.att_metid+"_"+this.att_myclass,  new INFOMETHODE(this.att_cpt_meth, x_5.att_signature, x_3.att_type, x_2.att_isStatic));
}
}
x_7.att_targs=-(x_5.att_depLB);
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#initBLOC","METHODE -> QUAL PTYPE #init MPARFS #initBLOC BLOC #code ;"});
}
  }
private void action_auto_inh_83(S_QUAL_MOC x_2, S_PTYPE_MOC x_3, S_MPARFS_MOC x_5, S_BLOC_MOC x_7) throws Exception {
try {
// instructions
x_3.att_tds=this.att_tds;
x_5.att_tds=this.att_tds;
x_7.att_myclass=this.att_myclass;
x_3.att_machine=this.att_machine;
x_5.att_machine=this.att_machine;
x_7.att_machine=this.att_machine;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#auto_inh","METHODE -> QUAL PTYPE #init MPARFS #initBLOC BLOC #code ;"});
}
  }
private void action_code_83(S_QUAL_MOC x_2, S_PTYPE_MOC x_3, S_MPARFS_MOC x_5, S_BLOC_MOC x_7) throws Exception {
try {
// locales
String loc_code;
// instructions
if (glob_83_const){
loc_code=this.att_machine.genConstructeur(glob_83_c, x_7.att_code);
this.att_code=loc_code;
}
else {
loc_code=x_5.att_metid+"_"+this.att_myclass+":;\n"+x_7.att_code;
if (x_3.att_type instanceof VOIDTYPE ){
this.att_code=loc_code+"RETURN (0)"+(-(x_5.att_depLB))+";\n";
}
else {
this.att_code=loc_code;

}
}
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#code","METHODE -> QUAL PTYPE #init MPARFS #initBLOC BLOC #code ;"});
}
  }
  public void analyser () throws Exception {
    regle83 () ;
  }
  }
